package com.bcu.cn.controller;

import com.bcu.cn.entity.VisitCounter;
import com.bcu.cn.service.VisitCounterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class WelcomeController {
    @Autowired
    private VisitCounterService service;

    @GetMapping("/")
    public String index(Model model) {
        service.increment();
        VisitCounter counter = service.getCurrentCount();
        model.addAttribute("count", counter.getCount());
        return "welcome"; // 注意：去掉 .jsp 后缀，由视图解析器自动拼接
    }
}